package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class ARRAYFactory extends AbstractTokenVisitorFactory {

	private static ARRAYFactory INSTANCE;
	
	private ARRAYEFactory arrayeFactory;
	private LambdaFactory lambdaFactory;
	
	public static ARRAYFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new ARRAYFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			arrayeFactory = ARRAYEFactory.getInstance();
			lambdaFactory = LambdaFactory.getInstance();
		}
	};
	
	
	private ARRAYFactory() throws Exception {

	}
	
	@Override
	public TokenVisitor makeChainedVisitor(final TokenVisitor siguiente) throws Exception {
		initializer.init();
		return arrayeFactory.makeChainedVisitor(lambdaFactory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();
		return arrayeFactory.makeChainedVisitor(lambdaFactory.makeVisitor());
	}
	
	
}
